class Animal {
    readonly name:string
    constructor(name) {
        this.name = name
    }
    // protected类及子类可以调用方法。实例中不允许调用
    run() {
        return `${this.name}is running`
    }
}
let snake = new Animal('zhangsan')
// snake.name = '123' //只读属性
console.log(snake.run())
class Dog extends Animal {
    bark() {
        return `${this.name} is barking`
    }
}
let taidi = new Dog('lisi')
console.log(taidi.run())
console.log(taidi.bark())

class Cat extends Animal {
    static catgory = 'nan'
    // 重写构造函数的话要用super关键字
    constructor(name) {
        super(name)
        console.log(this.name)
    }
    run() {
        return 'miao' + super.run()
    }
}
let cat1 = new Cat('dabai')
console.log(cat1.run())
console.log(Cat.catgory);
